package com.gsj.system.controller;

import com.gsj.common.pojo.R;
import com.gsj.common.utils.UploadUtil;
import com.gsj.system.config.OperLog;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @program: clms-eighth01
 * @description:上传controller
 * @author: 张巍蓝
 * @create: 2021-07-27 09:34
 **/
@RestController
@RequestMapping("/system")
public class UploadController {
    @PostMapping("upload")
    @OperLog( title= "图片上传",operatorType ="0",business_type = "0")
    public R upload(MultipartFile file){
        try{
            String upload = UploadUtil.Upload(file.getInputStream(), file.getOriginalFilename());
            return R.ok().put("path",upload);
        }catch(Exception e){
            return R.error();
        }

    }
}
